package org.xtext.runtime.lang;

import java.util.LinkedList;
import java.util.List;

import org.xtext.runtime.library.Library;

public class Prelude extends Library {
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@TERM
	public List<?> merge(List<?> list1, List<?> list2) {
		List toReturn = new LinkedList( list1 );
		toReturn.addAll( list2 );
		return toReturn;
	}
	
	@SuppressWarnings({"rawtypes"})
	@TERM List<?> valueAsList(List<?> list, int index) {
	   return (List) list.get( index );
	}
	
	@TERM
	public int size(List<?> list) {
		return list.size();
	}
	
	@TERM
	public String valueAsString(List<?> list, int index) {
		return list.get(index).toString();
	}

	@TERM
	public Integer valueAsInt(List<?> list, int index) {
		return (Integer) list.get(index);
	}

	@TERM
	public Long valueAsLong(List<?> list, int index) {
		return (Long) list.get(index);
	}

	@TERM
	public Float valueAsFloat(List<?> list, int index) {
		return (Float) list.get(index);
	}

	@TERM
	public Double valueAsDouble(List<?> list, int index) {
		return (Double) list.get(index);
	}

	@TERM
	public Character valueAsChar(List<?> list, int index) {
		return (Character) list.get(index);
	}
	
	@TERM
	public String toString(List<?> list) {
		return list.toString();
	}
	
	@TERM
	public String headAsString(List<String> list){
		return list.get(0);
	}
}
